import { request } from './util.js'

(async function login() {
  //准备参数
  let url = 'http://192.168.102.7:8888/api/private/v1/login'
  let params = {
    username: 'admin',
    password: '123456',
    method: 'GET'
  }
  //发起请求
  let { data: res } = await request(url, params)
  //解析结果
  let user = res.data
  //保存结果
  sessionStorage.setItem('user', JSON.stringify(user))
  //实现页面跳转
  let id = setTimeout(function() {
    location = 'goods.html'
    clearTimeout(id)
  }, 1000)
})()
